<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>linear-vertical-motion</title>
</head>
<body>
   <canvas id="canvas" width="500" height="500" style="background:#000;">
       you browser not support canvas!
   </canvas>
   <script src="../js/utils.js"></script>
   <script src="../js/ball.js"></script>
   <script>
       window.onload = function(){
           var canvas = document.getElementById('canvas');
           var context = canvas.getContext('2d');
           
           var angle = 0,
               range = 50,
               xspeed = 1,
               yspeed = 0.05;
           
           
           var ball = new Ball();
           
//           ball.x = canvas.width/4;
//           ball.y = canvas.height/4;
           
           (function drawFrame(){
               window.requestAnimationFrame(drawFrame,canvas);
               context.clearRect(0,0,canvas.width,canvas.height);
               
               ball.x += xspeed;
               if(ball.x > canvas.width+ball.radius){
                   ball.x = -ball.radius;
               }
               ball.y = canvas.height/2+Math.sin(angle)*range;
               
              // angle += 0.05; //加上就变成wave运动
               ball.draw(context);
               
           })();
          // ball.draw(context);
           
       }
    
    
    </script>
    
</body>
</html>